#ifndef THEME_H
#define THEME_H
#include <QMap>
#include "Include/ITheme.h"

struct ThemeChunk{
    QColor foreground;
    QColor selectForeground;
    QColor background;
    QColor selectBackground;
    QColor marginBackground;
    QColor marginForeground;
    QColor marginSelectForeground;
    bool bold;
    bool italic;
};
class QSettings;
class Theme : public QObject, public ITheme
{
    Q_OBJECT
    Q_INTERFACES(ITheme)
public:
    explicit Theme(const QString & set, QObject *parent = 0);
    Theme(const Theme & theme);
    virtual ~Theme();

    virtual QColor background();
    virtual void setBackground(QColor color);

    virtual QColor selectForeground();
    virtual void setSelectForeground(QColor color);

    virtual QColor selectBackground();
    virtual void setSelectBackground(QColor color);

    virtual QColor marginBackground();
    virtual void setMarginBackground(QColor color);

    virtual QColor marginForeground();
    virtual void setMarginForeground(QColor color);

    virtual QColor marginSelectForeground();
    virtual void setMarginSelectForeground(QColor color);

    virtual void setLexer(const QString & lexerName);

    virtual QColor foreground(const QString & key, QColor defColor = Qt::black);
    virtual void setForeground(const QString & key, QColor color);

    virtual bool bold(const QString & key);
    virtual void setBold(const QString & key, bool isBold);

    virtual bool italic(const QString & key);
    virtual void setItalic(const QString & key, bool isItalic);

    virtual bool save();
private:
    void readConf(QSettings & set);
    void setColor(QSettings& set, const QString & key, QColor color);
private:
    QString _set;
    QString _currentLexer;
    QMap<int, QString> _mapIdName;
    QMap<QString, QMap<QString, ThemeChunk> > _map;
    ThemeChunk _defaultChunk;
};

#endif // THEME_H
